import { $get } from '@js/authRequest'
import { decomporessListLicenseAndMobileAndBank } from '@src/assets/js/tool'

// 获取字典信息
export async function getDictinarys (types = []) {
  const res = await $get('/api/xapc/dictionary', {
    types: types.join()
  })
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return formatDictionaries(res.data)
}

// 格式化枚举字典
function formatDictionaries (dictionaries = []) {
  const result = {}
  dictionaries.forEach(d => {
    result[d.type] = d.list
  })
  return result
}

// 获取案件仲裁员列表
export async function getArbitratorList (caseid) {
  const res = await $get(`/api/xapc/case/${caseid}/arbitrator`)
  if (res.status !== 1) {
    return new Error(res.message)
  }
  decomporessListLicenseAndMobileAndBank(res.data)
  return res.data
}
